sharedfs: skip hypervisors without system templates - #13830
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 4.22 #13830 +/- ##
============================================
- Coverage 17.69% 17.69% -0.01%
Complexity 15835 15835
============================================
Files 5925 5925
Lines 533539 533541 +2
Branches 65274 65275 +1
============================================
- Hits 94427 94424 -3
- Misses 428435 428442 +7
+ Partials 10677 10675 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@blueorangutan package |
|
@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 18819 |
|
@blueorangutan test |
|
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
|
[SF] Trillian test result (tid-16736)
|
|
@blueorangutan package |
|
@shwstppr a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 19081 |
shwstppr
left a comment
There was a problem hiding this comment.
Tested with a KVM and VMware mixed zone. VMware systemvm template was not present
Before fix, error was seen:
(localcloud) 🐱 > create sharedfilesystem filesystem=xfs diskofferingid=e53beb0a-5445-4b7d-8de7-4744314493db networkid=d79c34cf-4cec-4d4c-abba-77ae77856a72 serviceofferingid=67343c26-3788-4285-86d3-061e1a62591b zoneid=105faafc-5356-4280-ae1e-498732d49c40 name=abc1
{
"account": "admin",
"accountid": "1a34a13e-ab57-11f1-b57c-1e00b20009a0",
"cmd": "org.apache.cloudstack.api.command.user.storage.sharedfs.CreateSharedFSCmd",
"completed": "2026-09-08T11:32:14+0000",
"created": "2026-09-08T11:32:14+0000",
"domainid": "c9db7340-ab56-11f1-b57c-1e00b20009a0",
"domainpath": "ROOT",
"jobid": "147472a9-9ffa-4129-9daf-c0e250131c52",
"jobinstancetype": "SharedFS",
"jobprocstatus": 0,
"jobresult": {
"errorcode": 530,
"errortext": "Cannot invoke \"com.cloud.storage.VMTemplateVO.getId()\" because \"template\" is null"
},
"jobresultcode": 530,
"jobresulttype": "object",
"jobstatus": 2,
"userid": "1a352d7a-ab57-11f1-b57c-1e00b20009a0"
}
🙈 Error: async API failed for job 147472a9-9ffa-4129-9daf-c0e250131c52
After fix, deployment always happened on the KVM cluster.
| if (template == null && !iter.hasNext()) { | ||
| if (template == null) { | ||
| if (iter.hasNext()) { | ||
| continue; |
There was a problem hiding this comment.
Maybe a log here would be helpful
The 4.22 merge brought in testDeploySharedFSContinuesWhenTemplateIsMissingForNonLastHypervisor from PR apache#13830, which covers the same skip-hypervisor-without-template path as testDeploySharedFSSkipsHypervisorWithoutTemplate. It was written against getSupportedHypervisorTypes(zoneId, false, null); deploySharedFSVM() now passes forSystemVm=true, so its stubs were never used and MockitoJUnitRunner failed the class with UnnecessaryStubbingException. Its External hypervisor scenario is also unreachable now, since forSystemVm=true filters External out. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Fixes #13825
Summary
Prevent
CreateSharedFileSystemfrom dereferencing a missing system VM template when a zone contains mixed hypervisor types.Root cause
deploySharedFSVM()shuffles the supported hypervisors. When a hypervisor has no ready system VM template and another hypervisor remains, the existing null check fell through totemplate.getId()instead of trying the next hypervisor. This caused the reported intermittent NPE for mixed zones such as VMware plus External/MaaS.Fix
Skip hypervisors without a ready system VM template while alternatives remain. Preserve the existing explicit
CloudRuntimeExceptionwhen the final candidate also has no template.Validation
template is nullNPE occurred on the External-first attempt.4.22branch with the exact NPE.Scope
This is limited to SharedFS hypervisor template selection and its regression test. No UI, API contract, database schema, or deployment behavior is changed.